import { createRouter, createWebHistory } from "vue-router";
import LoginView from "@/views/login/LoginView.vue";
import LayoutView from "@/views/layout/LayoutView.vue";
import BlogListView from "@/views/blog/BlogListView.vue";
import BlogEditView from "@/views/blog/BlogEditView.vue";

const routes = [
  {
    path: "/login",
    component: LoginView,
  },
  {
    path: "/",
    component: LayoutView,
    children: [
      { path: "", redirect: "/blogs" },
      { path: "blogs", component: BlogListView },
      { path: "blogs/edit/:id?", component: BlogEditView },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
